#include<bits/stdc++.h>//P37
using namespace std;
void find_sum(int a[],int n,int m){
    sort(a,a+n);
    int i=0,j=n-1;
    while(i<j){
        int sum=a[i]+a[j];
        if(sum>m)j--;
        if(sum<m)i++;
        if(sum==m){
            cout<<a[i]<<" "<<a[j]<<endl;
            i++;
        }
    }
}
int main(){
    int a[10];
    //{21,4,5,6,13,65,32,9,23};
    int n,i=0;
    int m=28;
    while(cin>>a[i]){
        if(cin.get()!='\n')i++;
        else break;
    }
    n=i+1;
    cin>>m;
    find_sum(a,n,m);
}